#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<ctime>
using namespace std;
const int N = 5e6 + 10;
int a[N];
int n, k;
int get(int l, int r)
{
    return a[rand() % (r - l + 1) + l];

}
int ks(int left, int right, int k)
{
    if (left >= right)
        return a[left];
    int g = get(left, right);
    int cn1 = left - 1;
    int i = left;
    int cn2 = right + 1;
    while (i < cn2)
    {
        if (a[i] < g)
        {
            swap(a[++cn1], a[i++]);
        }
        else if (a[i] == g)
        {
            i++;
        }
        else
        {
            swap(a[--cn2], a[i]);
        }
    }
    int a = cn1 - left + 1;
    int b = cn2 - cn1 - 1;
    int c = right - cn2 + 1;
    if (k <= a)
    {
        return ks(left, cn1, k);
    }
    else if (k <= a + b)
    {
        return g;
    }
    else
    {
        return ks(cn2, right, k - a - b);
    }
}
int main()
{
    srand(time(0));
    scanf("%d %d", &n, &k);
    k++;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    printf("%d", ks(1, n, k));
    return 0;
}